package cn.tedu.sp02.service;

import cn.tedu.sp01.pojo.Item;
import cn.tedu.sp01.service.ItemService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author: Li zi long
 * @date: 2021/10/18 11:45
 * @description:
 */
@Slf4j
@Service
public class ItemServiceImpl implements ItemService {
    @Override
    public List<Item> getItems(String OrderId) {
        log.info("获取商品列表, orderId = " + OrderId);
        //Demo数据
        ArrayList<Item> items = new ArrayList<>();
        items.add(new Item(1, "商品1", 1));
        items.add(new Item(2, "商品2", 4));
        items.add(new Item(3, "商品3", 1));
        items.add(new Item(4, "商品4", 2));
        items.add(new Item(5, "商品5", 6));
        return items;
    }

    @Override
    public void decreaseNumber(List<Item> items) {
        for (Item item : items) {
            log.info("减少库存: " + item);
        }
    }
}
